# ------------------- ${app.app} ------------------- #

apiVersion: apps/v1
kind: Deployment
metadata:
${"  "}name: ${app.app}
spec:
${"  "}replicas: ${appEnv.replicas}
${"  "}minReadySeconds: 120
${"  "}strategy:
${"    "}type: RollingUpdate
${"    "}rollingUpdate:
${"      "}maxSurge: 1
${"      "}maxUnavailable: 1
${"  "}selector:
${"    "}matchLabels:
${"      "}app: ${app.app}
${"  "}template:
${"    "}metadata:
${"      "}labels:
${"        "}app: ${app.app}
${"    "}spec:
${"      "}hostAliases:
${"        "}- ip: "123.103.9.104"
${"          "}hostnames:
${"            "}-  "dev.yonyougov.top"
${"      "}imagePullSecrets:
${"      "}- name: zwdev
${"      "}containers:
${"      "}- name: ${app.app}
<#if appEnv.image??>
${"        "}image: ${appEnv.image}
<#else>
${"        "}image: dockerhub.yonyougov.top/crux/${app.app}:${appEnv.packageVersion}
</#if>
${"        "}imagePullPolicy: Always
<#if appEnvConfigItemList?? && (appEnvConfigItemList?size > 0) >
${"        "}env:
<#list appEnvConfigItemList as appEnvConfigItem>
${"        "}- name: ${appEnvConfigItem.name}
${"          "}value: ${appEnvConfigItem.value}
</#list>
</#if>
${"        "}envFrom:
${"        "}- configMapRef:
${"            "}name: fap-env
${"        "}volumeMounts:
${"        "}- name: host-time
${"          "}mountPath: /etc/localtime
<#if appEnv.healthCheck>
${"        "}livenessProbe:
${"          "}httpGet:
<#if app.healthCheckPath??>
${"            "}path: ${app.healthCheckPath}
<#else>
${"            "}path: /${app.app}/healthcheck
</#if>
<#if app.healthCheckPort??>
${"            "}port: ${app.healthCheckPort}
<#else>
${"            "}port: 8080
</#if>
${"            "}httpHeaders:
${"            "}- name: Health-Check
${"              "}value: OK
${"          "}initialDelaySeconds: 600
${"          "}periodSeconds: 60
</#if>
<#if appEnv.useAdapter>
${"      "}- name: cse-proxy
${"        "}image: dockerhub.yonyougov.top/crux/crux-adapter-cse-proxy
${"        "}imagePullPolicy: Always
${"        "}envFrom:
${"        "}- configMapRef:
${"            "}name: fap-env
${"      "}- name: cse-invoker
${"        "}image: dockerhub.yonyougov.top/crux/crux-adapter-cse-invoker
${"        "}imagePullPolicy: Always
${"        "}envFrom:
${"        "}- configMapRef:
${"            "}name: fap-env
${"        "}env:
${"        "}- name: SERVICE_NAME
${"          "}value: ${app.app}
</#if>
${"      "}volumes:
${"      "}- name: host-time
${"        "}hostPath:
${"          "}path: /etc/localtime

<#if appEnvPortList?? && (appEnvPortList?size > 0) >
---
apiVersion: v1
kind: Service
metadata:
${"  "}name: ${app.app}-svc
spec:
${"  "}type: NodePort
${"  "}selector:
${"    "}app: ${app.app}
${"  "}ports:
<#list appEnvPortList as appEnvPort>
${"  "}- protocol: TCP
<#if appEnvPort.mappingPort??>
${"    "}nodePort: ${appEnvPort.mappingPort}
</#if>
${"    "}port: ${appEnvPort.port}
${"    "}targetPort: ${appEnvPort.port}
${"    "}name: ${appEnvPort.name}
</#list>
</#if>
